Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support completable animations in Compose tests #2051

Merged
merged 1 commit into from
Apr 5, 2022

Conversation

headsvk
Copy link
Contributor

@headsvk headsvk commented Apr 4, 2022

The change in #1987 to always use withInfiniteAnimationFrameNanos prevents non-infinite animations from completing in Compose tests.

I added a simple check to use withFrameNanos or withInfiniteAnimationFrameNanos based on the number of iterations. This fixes tests that wait for animations to complete, see sample WalkthroughAnimationTest. And InfiniteAnimationTest still passes.

Let me know if I'm missing some other use case.

@headsvk headsvk force-pushed the feature/complete-animation branch from 44a573d to e9db247 Compare April 4, 2022 16:18
return if (iterations == LottieConstants.IterateForever) {
// We use withInfiniteAnimationFrameNanos because it allows tests to add a CoroutineContext
// element that will cancel infinite transitions instead of preventing composition from ever going idle.
withInfiniteAnimationFrameNanos { frameNanos: Long ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
withInfiniteAnimationFrameNanos { frameNanos: Long ->
withInfiniteAnimationFrameNanos { frameNanos ->

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, fixed this copy paste

onFrame(iterations, frameNanos)
}
} else {
withFrameNanos { frameNanos: Long ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
withFrameNanos { frameNanos: Long ->
withFrameNanos { frameNanos ->

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, fixed this copy paste

@headsvk headsvk force-pushed the feature/complete-animation branch from e9db247 to 9ef8491 Compare April 4, 2022 16:26
@LottieSnapshotBot
Copy link

Snapshot Tests
28: Report Diff

@headsvk headsvk requested a review from gpeal April 5, 2022 07:40
@gpeal gpeal merged commit ca2f8a5 into airbnb:master Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants